#ifndef _CORE_
#define _CORE_

#include "base.h"

#include "NetIO.h"
#include "..\Scene\SceneManager.h"

#include "hge\hge.h"
#include "hge\hgeresource.h"
#include "hge\hgegui.h"

namespace air {
	
	class IObject;
	class IGuiObject;
	class IScene;
	class Acc;
	/**
	* @brief Graphic Component
	*/
	class Core {
	public:
		
		static Core* create();
		static void release();

		bool initiate();
		void start();
		bool addScene(IScene*);
		NetIO* getNetIO() { return &netIO; }

	private:
		Core();
		~Core();
		bool loadResource();
		/**
		 * @brief logic process function hge will call every frame
		 *
		 * @param dt time elapsed since last called
		 *
		 * @return bool false for continue running. true for end.
		 */
		inline static bool frameFunc()
		{
			float dt = instance->hge->Timer_GetDelta();
			return instance->scenes.update(dt);
		}
		/**
	 	 * @brief render function hge will call every frame
	 	 *
		 * @param dt same with frameFunc(float dt)
		 *
		 * @return same with frameFunc(float dt)
		 */
		inline static bool renderFunc()
		{
			float dt = instance->hge->Timer_GetDelta();
			instance->hge->Gfx_BeginScene();
			instance->scenes.render(dt);
			instance->hge->Gfx_EndScene();
			return false;
		}
		/**
		 * @brief pointer to Core singleton. guaranteed to be NULL when unavailable
		 */
		static Core* instance;
		/**
		 * @brief Network Component
		 */
		NetIO netIO;
		/**
		 * @brief Scene Manager
		 */
		SceneManager scenes; 
		HGE* hge;
		hgeResourceManager hgeResMan;
	};
}


#endif
